package com.bjtu.laorenyouhao.yigong.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bjtu.laorenyouhao.yigong.entity.LaorenYigongEntity;
import com.bjtu.laorenyouhao.yigong.service.LaorenYigongService;
import com.bjtu.common.utils.PageUtils;
import com.bjtu.common.utils.R;



/**
 * 老人义工信息
 *
 * @author yangyalong
 * @email yangyalong@gmail.com
 * @date 2021-07-08 21:02:42
 */
@RestController
@RequestMapping("yigong/laorenyigong")
public class LaorenYigongController {
    @Autowired
    private LaorenYigongService laorenYigongService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = laorenYigongService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		LaorenYigongEntity laorenYigong = laorenYigongService.getById(id);

        return R.ok().put("laorenYigong", laorenYigong);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LaorenYigongEntity laorenYigong){
		laorenYigongService.save(laorenYigong);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LaorenYigongEntity laorenYigong){
		laorenYigongService.updateById(laorenYigong);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		laorenYigongService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
